package hk.edu.polyu.comp.motioncapture;

import org.xvolks.jnative.exceptions.*;
import org.xvolks.jnative.misc.basicStructures.*;
import org.xvolks.jnative.pointers.*;
import org.xvolks.jnative.pointers.memory.*;

public class RECT extends AbstractBasicData<RECT> {
	LONG left; // 4
	LONG top; // 4
	LONG right; // 4
	LONG bottom; // 4

	// Total: 16

	protected RECT() throws NativeException {
		super(null);
		mValue = this;

		createPointer();

		left = new LONG(0);
		top = new LONG(0);
		right = new LONG(0);
		bottom = new LONG(0);
	}

	public RECT getValueFromPointer() throws NativeException {
		offset = 0;
		left = new LONG(getNextInt());
		top = new LONG(getNextInt());
		right = new LONG(getNextInt());
		bottom = new LONG(getNextInt());
		return getValue();
	}

	public int getSizeOf() {
		return 16;
	}

	public Pointer createPointer() throws NativeException {
		pointer = new Pointer(new GlobalMemoryBlock(getSizeOf()));
		pointer.setIntAt(0, getSizeOf());
		return pointer;
	}

	public int getLeft() {
		return left.getValue();
	}

	public void setLeft(LONG left) throws NativeException {
		this.left = left;
		pointer.setIntAt(0, left.getValue());
	}

	public int getTop() {
		return top.getValue();
	}

	public void setTop(LONG top) throws NativeException {
		this.top = top;
		pointer.setIntAt(4, left.getValue());
	}

	public int getRight() {
		return right.getValue();
	}

	public void setRight(LONG right) throws NativeException {
		this.right = right;
		pointer.setIntAt(8, left.getValue());
	}

	public int getBottom() {
		return bottom.getValue();
	}

	public void setBottom(LONG bottom) throws NativeException {
		this.bottom = bottom;
		pointer.setIntAt(12, left.getValue());
	}

	public String toString() {
		return String.format("%d %d %d %d", left.getValue(), top.getValue(),
				right.getValue(), bottom.getValue());
	}
}
